package com.huffman.smart_picture.utils;


import com.huffman.smart_picture.common.exception.ErrorEnum;
import com.huffman.smart_picture.common.base.reponse.ResponseResult;

/**
 * @author DengLin
 * @title 快捷响应数据工具
 * @date 2024/06/27
 */
public class ResponseUtil {

    public static ResponseResult success() {
        return new ResponseResult(200, "请求成功", "", null);
    }

    public static <T> ResponseResult success(T data) {
        return new ResponseResult<T>(200, "请求成功", "", data);
    }

    public static <T> ResponseResult success(T data, String description) {
        return new ResponseResult<>(200, "请求成功", description, data);
    }

    public static <T> ResponseResult success(T data, String message, String description) {
        return new ResponseResult<>(200, message, description, data);
    }

    public static ResponseResult fail(ErrorEnum errorEnum) {
        return new ResponseResult(errorEnum.getCode(), errorEnum.getMessage(), errorEnum.getDescription(), null);
    }

    public static ResponseResult fail(Integer code, String message, String description) {
        return new ResponseResult(code, message, description, null);
    }
}